package com.ce.study.procum;

import java.util.concurrent.ConcurrentHashMap;

public class TestConcurrentHashMap {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		final ConcurrentHashMap<String, Long> cmap = new ConcurrentHashMap<String, Long>();
		cmap.put("key", System.currentTimeMillis());
		Thread thwrite = new Thread() {
			@Override
			public void run() {
				while(true) {
					cmap.put("key", System.currentTimeMillis());
				}
			}
			
		};

		Thread thread = new Thread() {
			@Override
			public void run() {
				while(true) {
					long t1 = cmap.get("key");
					long t2 = cmap.get("key");
					if(t1!=t2)
						System.out.println("t1="+t1+"  t2="+t2);
//					else
//						System.out.println("================t1="+t1+"  t2="+t2);
				}
			}
			
		};
		
		thwrite.start();
		thread.start();
		System.out.println("");
	}

}
